<template>
  <div class="w-page w-stat">
    <div class="w-head">
      <img src="../assets/img/second/banner3.png" alt="">
    </div>
    <div class="w-part1 w-part">
      <div class="w-title flex vc">
        <p class="w-shu"></p>
        <p>捐赠项目</p>
      </div>
      <van-tabs class="w-tabs" line-width='0' v-model="active" animated color="#762A2A" background="rgba(255,255,255,0)"
                :border='false' title-active-color="#762A2A">
        <van-tab v-for="(v,i) in cardList" :key="i">
          <div slot="title">{{v}}</div>
          <ul v-if="i==0">
            <li v-for="(v,i) in list1" :key="i" class="w-li flex hb vc">
              <div class="w-name">{{v.projectTitle}}</div>
              <div class="w-pro shrink0" >
                <van-progress :percentage="(v.income/v.objective)*100" :show-pivot="false" color="linear-gradient(to right, #be99ff, #F09D5E)" />
              </div>
              <div class="w-num">￥{{v.income}}元</div>
            </li>
          </ul>
          <ul v-if="i==1">
            <li v-for="(v,i) in list2" :key="i" class="w-li flex hb vc">
              <div class="w-name">{{v.projectTitle}}</div>
              <div class="w-pro shrink0">
                <van-progress :percentage="100" :show-pivot="false" color="linear-gradient(to right, #be99ff, #F09D5E)"/>
              </div>
              <div class="w-num">{{v.donors}}人</div>
            </li>
          </ul>
        </van-tab>
      </van-tabs>
      <div>

      </div>
      <div class="tabCon">

      </div>
    </div>
    <div class="w-part3 w-part">
      <div class="w-title flex vc">
        <p class="w-shu"></p>
        <p>线上捐赠TOP10</p>
      </div>
      <ul>
        <li v-for="(v,i) in list3" :key="i" class="w-li3 flex hb vc">
          <div class="w-peoplebox flex vc">
            <p class="w-sort">{{i}}</p>
            <p class="w-people">{{v.nickname}}</p>
          </div>
          <p class="shrink0">{{v.donate}}元</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { income, donors, rank } from '@/api/statistics'
import {
  Progress,
  Tab,
  Tabs
} from 'vant'
var colorList = ['#D870F7', '#FCD072', '#5A99F3', '#9AE26A']

export default {
  components: {
    [Progress.name]: Progress,
    [Tab.name]: Tab,
    [Tabs.name]: Tabs
  },
  data () {
    this.chartSettings = {
      offsetY: 140,
      radius: [50, 60],
      label: {
        normal: {
          formatter: '{d}%'
        }
      },
      itemStyle: {
        color: function (params) {
          return colorList[params.dataIndex]
        }
      }
    }
    return {
      active: 0,
      cardList: ['按总额', '按人次'],
      list1: [],
      list2: [],
      list3: []
    }
  },
  created () {
    income().then(response => {
      this.list1 = response.data
    })
    donors().then(response => {
      this.list2 = response.data
    })
    rank().then(response => {
      this.list3 = response.data.list
    })
  },
  methods: {
    getNum (index) {
      this.active = index
    }
  }
}
</script>
<style>
  .van-tabs--line .van-tabs__wrap {
    overflow: hidden;
  }

  .w-stat .van-tabs__nav--line {
    width: 42vw;
    float: right;
  }

  .w-stat .van-tab--active {
    border: 1px solid #762A2A;
  }

  .w-stat .van-tab {
    height: 29px;
    line-height: 28px;
    border-radius: 20px;
    border: 1px solid #7D7D7D;
    margin-left: 10px;
    font-size: 13px;

  }
  .van-progress__portion{
    max-width: 100%;
  }
</style>
<style scoped>
  .w-page {
    padding-bottom: 40px;
  }

  .w-head img {
    width: 100%;
  }

  .w-shu {
    margin-right: 4px;
    width: 3px;
    height: 16px;
    background: #7A2B26;
  }

  .w-part {
    padding: 0 20px;
  }

  .w-title {
    font-size: 18px;
    color: #434343;
    font-weight: bold;
    margin-top: 20px;
    margin-bottom: 6px;
  }

  .w-li {
    padding: 8px 0px;
    position: relative;
  }

  .w-name {
    font-size: 12px;
    color: #707070;
    width: 22%;
  }

  .w-num {
    font-size: 13px;
    color: #434343;
    width: 20%;
  }

  .w-pro {
    /* position: relative; */
    width: 48%;
    left: 0;
  }

  .w-li3 {
    font-size: 15px;
    color: #313131;
    margin-top: 12px;
  }

  .w-sort {
    margin-right: 12px;
  }

  .w-peoplebox {
    width: 76%;
  }

  .w-people {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .w-cir {
    height: 58vw;
    overflow: hidden;
    margin-top: 20px;
  }

  .w-tabs {
    margin-top: -30px;
  }

  .w-cir canvas {
  }
</style>
